#encoding=utf-8
import socket
import time
 
host = "192.168.137.84"      #服务器ip
#一号机：192.168.137.84
#二号机:192.168.137.59
#host = "127.0.0.1"      #服务器ip
port = 6667               #服务器端口号
A = [2.13,',',2.14]
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    # 选择IPv4地址以及TCP协议
print ("通信服务开启")
mySocket.bind((host, port))   # 绑定端口
mySocket.listen(5)       # 监听这个端口，可连接最多5个设备
str2 = ''.join(str(i) for i in A)
mssg = str2.encode()
if __name__ == '__main__':
    while True:  
        client, address = mySocket.accept()           # 接受客户端的连接请求
        try:  
            client.settimeout(120)                 # 设置2min时限
            client.send(mssg)     # 发送消息  
            time.sleep(5)
        except socket.timeout:                # 超时
            print ('time out')
        
    mySocket.close()          # 关机
